/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jxtafileshare;

import java.text.MessageFormat;
import net.jxta.peer.PeerID;
import net.jxta.peergroup.PeerGroupID;
import net.jxta.pipe.PipeID;

import java.net.UnknownHostException;
import java.net.InetAddress;
import net.jxta.document.AdvertisementFactory;

/**
 *
 * @author Danny
 */
public class Main {

    public static void main(String args[]) {

        PeerGroupID infra = IDCreator.createInfraPeerGroupID("infra");
        PeerID peerID = IDCreator.createPeerID(infra, "peer");
        PipeID pipeID = IDCreator.createPipeID(PeerGroupID.defaultNetPeerGroupID, "pipe");

        peerID = IDCreator.createNewPeerID(PeerGroupID.defaultNetPeerGroupID);
        pipeID = IDCreator.createNewPipeID(PeerGroupID.defaultNetPeerGroupID);
        PeerGroupID pgid = IDCreator.createNewPeerGroupID(PeerGroupID.defaultNetPeerGroupID);

        AdvertisementFactory.registerAdvertisementInstance(
                PeerAdvertisement.getAdvertisementType(),
                new PeerAdvertisement.Instantiator());

        PeerAdvertisement peerAdv = new PeerAdvertisement();
        peerAdv.setID(peerID);
        peerAdv.setName("Daniel");
        peerAdv.setGroupID(pgid);
        try {
            peerAdv.setIP(InetAddress.getLocalHost().getHostAddress());
        } catch(UnknownHostException ignored) {
            // ignored
        }
        System.out.println(peerAdv.toString());
    }
}
